// 轮播图
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperView extends StatefulWidget {
  @override
  _SwiperViewState createState() => _SwiperViewState();
}

class _SwiperViewState extends State<SwiperView> {
  List<String> imgNames = [
    "images/test/test01.png",
    "images/test/test02.png",
    "images/test/test03.png",
    "images/test/test04.png",
    "images/test/test05.png",
    "images/test/test06.png",
  ];

  @override
  Widget build(BuildContext context) {
    return Swiper(
      itemCount: imgNames.length,
      itemBuilder: (context, index) {
        // ClipRRect实现圆角
        return ClipRRect(
          child: Image.asset(
            imgNames[index],
            fit: BoxFit.fill,
          ),
          borderRadius: BorderRadius.circular(10),
        );
      },
      pagination: SwiperPagination(
          builder: DotSwiperPaginationBuilder(
              color: Colors.grey, activeColor: Colors.red)),
      controller: SwiperController(),
      autoplay: true,
    );
  }
}